/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package net.wofly.sale.commission.repository;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import net.wofly.sale.commission.domain.CommissionCfg;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface CommissionCfgRepository
		extends PagingAndSortingRepository<CommissionCfg, String>, JpaSpecificationExecutor<CommissionCfg> {

	@Query(value = "select cc from CommissionCfg cc where cc.userID = :userID and cc.status = 1 order by cc.modifyDate desc")
	List<CommissionCfg> findByUserID(@Param("userID") String userID);

	@Query(value = "select cc from CommissionCfg cc where cc.userID = :userID and cc.roleID = :roleID and cc.status = " +
			"1 order by cc.modifyDate desc")
	List<CommissionCfg> findByRoleIDAndUserID(@Param("roleID") String roleID, @Param("userID")String userID);
}